package com.atguigu.mybatis.mappers;

import com.atguigu.mybatis.bean.Employee;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * Created by Smexy on 2022/9/6
 *
 *  Dao ，Mapper
 */
public interface EmployeeMapper
{
    //一套增删改查
    Employee getEmployeeById(Integer id);

    void insertEmployee(Employee employee);

    void deleteEmployeeById(Integer id);

    void updateEmployee(Employee employee);

    List<Employee> getAll();


    /*
           select * from tbl_employee where id = #{jljaelkjfalkfj}
    报错如下:
        BindingException:  绑定异常。 一般指参数无法传入到sql或sql无法和接口的方法绑定
                Parameter 'jljaelkjfalkfj' not found. Available parameters are [arg1, arg0, param1, param2]

          原理：  如果接口的参数列表有多个参数，底层会使用一个Map进行封装，Map的key固定为 arg0----argN-1 及 param1---paramN

            Employee employee = mapper.getEmployeeById2("aaa",1);

            Map{ arg0 = 'aaa',arg1 = 1, param1 = 'aaa',param2 = 1          }

            #{xxxx}: 会以xxxx为key从Map中去对应的key所对应的value


       @Param("xxx"): 固定为这个参数起一个key，名为xxx，放入参数Map中
            Map{ name = 'aaa',empId = 1....          }

     */
    Employee getEmployeeById2(@Param("name") String tableName, @Param("empId") Integer id);
}
